If, like me, you like to experiment with LB code in a variety of different Directories, then in the course of time you will build up a collection of ever expanding ERROR.LOG files. Thanks to Mark Parkinson’s ever useful search routine, this simple little program locates all the error.log files on the current drive in use, creates a list, then offers the user a choice of deleting all at once or individually after confirming.
I have checked both individual and all at once. Either choice works safely and correctly, but beware of making careless alterations to the KILL parameters, which could lead to loss of important files needed to run your systems.
Also there are occasions when retaining a certain error.log for some time can be useful. This is especially true if you are still working on a program in the relevant Directory. With respect to Carl and LB, I personally have seldom found the information in these files to have any great meaning for me, being produced in a strange pseudo language of their own. I do know that Carl gets a great deal of information from them, such as when eliminating odd Bugs, and when asking us to help test new Beta versions of LB.
Gordon Sweet
Gordon's Webpage site for LB CODE has been moved to
' Clearing out error.logs in different directories by Gordon Sweet
' With acknowledgents to Mark Parkinson for the Recursive Files routine
nomainwin
dim file$(1000,2) : dim info$(10, 10) : dim Q(2)
ux = 1 : uy = 1 ' determine Display used
if DisplayWidth > 1000 then ux = 120 : uy = 90
[start]
UpperLeftX = ux : UpperLeftY = uy
WindowWidth = 800 : WindowHeight = 600
open "SEARCH FOR error.log" for graphics_nf_nsb as #m
redim file$(1000,2) : redim info$(10, 10) : redim Q(2)
#m "discard; trapclose [quit]; down"
#m "font ariel 14 bold; place 200 250"
#m "\PLEASE WAIT FILE LIST BEING CREATED"
DRV$ = left$(DefaultDir$,2) 'WORKS FROM ROOT DIR
#m "\OF ALL OF THE error.log FILES on Drive ";DRV$
' ADAPTED FROM recurse files.bas for LB3 by Mark Parkinson - 08/10/02
'Note no backslash - added later on.
placetohunt$=DRV$ : thingtohuntfor$="error.log"
C = Q(1) : call recurse placetohunt$, thingtohuntfor$
for f = 1 to Q(1)
tfile$=file$(f,1)
t$="" : ltr = len(tfile$)
while t$<>"\"
t$ = mid$(tfile$,ltr,1)
ltr = ltr -1
wend
n = len(tfile$)-ltr-1
file$(f,2) = right$(tfile$,n)
if len(file$(f,2))>18 then file$(f,2)=left$(file$(f,2),18)
next f
#m "cls; font arial 10 bold; place 50 20"
for h = 1 to Q(1)
#m "|";h;" = ";file$(h,1)
next h
#m "color red"
if Q(1) = 0 then
#m "\NO error.log FILES TO BE FOUND ON DRIVE ";DRV$
notice "OK"
goto [quit]
end if
#m "\Enter the A to Delete ALL, I individually, R re-search, or Cancel to abort"
#m "flush; place 30 20" : playwave "chimes"
[which]
q$ = "" : prompt "which?"; q$
if q$ ="" then [quit]
if q$ = "R" or q$= "r" then close #m : goto [start]
if q$ = "A" or q$ = "a" then [all]
if q$ = "I" or q$ = "i" then [single]
notice "kill";file$(f,1)
wait
[all]
for e = 1 to Q(1)
kill file$(e,1)
#m "|";file$(e,1); " DELETED"
next e
notice "Done" : close #m : goto [start]
[single]
for e = 1 to Q(1)
conf$ = "Delete ";e;" = ";file$(e,1)
confirm conf$;del$
if del$ = "yes" then
kill file$(e,1)
#m "|";file$(e,1);" DELETED"
else
#m "\ "
end if
next e
notice "Done" : close #m : goto [start]
[quit]
close #m : end
Function noPath$(t$)
while instr(t$, "\")
t$ = mid$(t$, 2)
wend
noPath$ = t$
end function
Function GetShortPathName$(lPath$)
lPath$=lPath$+chr$(0)
sPath$=space$(256)
lenPath=len(sPath$)
open "kernel32" for dll as #k
calldll #k, "GetShortPathNameA",lPath$ as ptr,_
sPath$ as ptr,lenPath as long,r as long
close #k
GetShortPathName$=left$(sPath$,r)
end function
sub recurse pathspec$,mask$
'Put in the backslash separator.
pathspec$=pathspec$+"\"
files pathspec$, mask$, info$(
filecount=val(info$(0, 0))
subdircount=val(info$(0, 1))
for i=1 to filecount
filename$= pathspec$+info$(i, 0)
filesize$= info$(i, 1)
datestamp$=info$(i, 2)
if instr(filename$,"Filemenu")>0 then [miss]
if instr(filename$,"Run.exe")>0 then [miss]
Q(1) = Q(1) + 1
file$(Q(1),1) = upper$(filename$)
[miss] next i
for i=1 to subdircount
list$=list$+pathspec$+info$(f + i, 1)+"*"
next i
while list$<>""
p=instr(list$,"*")
p$=left$(list$,p-1)
call recurse p$,mask$
list$=mid$(list$,p+1)
wend
end sub
[boxhold]
open "user32" for dll as #user ' prevents losing box
toTop=(-1 or 0)
flags=_SWP_NOMOVE or _SWP_NOSIZE
calldll #user,"SetWindowPos",mainH as ushort,toTop as short,_
0 as short,0 as short,0 as short,0 as short,flags as ushort,_
result as void
close #user : return